<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<html>
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	    <title>权限管理</title>
		<link type="text/css" rel="stylesheet" href="${ctx}/static/tools/jquery-validationEngine/validationEngine.jquery.css"></link>
		<link rel="stylesheet" href="${ctx}/static/threadui/css/select_css/style.css" />
		<link rel="stylesheet" href="${ctx}/static/threadui/css/select_css/select.css" />
		<link type="text/css"  rel="stylesheet" href="${ctx}/static/threadui/css/style.css">
	    <style type="text/css">
			.select_option{
				width: 180px;
				z-index: 1;
				position: absolute;
			}
			.select_showbox{
				width: 175px;
			}
			.checkRole{
				width: 45%;
				float: left;
				border-radius: 3px;
				box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
				cursor: text;
				line-height:22px;
				padding: 4px 6px;
				border: 1px solid #CAC5C5;
				margin-top: 5px;
				min-height: 100px;
				height: auto;
			}
			.checkRole attr{
				color: red;
			}
			.tenant_fill{width:100%}
			.tag{
				color: white;
				margin-right: 2px;
				padding: 0.2em 0.6em 0.3em;
				border-radius: 0.25em;
				color: white;
				font-size: 95%;
				line-height: 20px;
				text-align: center;
				white-space: nowrap;
				margin-top: 1px;
			}
			.label-success{
				background-color: #29C129;
			}
			.label-default{
				background-color: #7E7575;
			}
			.tag [class="tag-remove"]::after{
				content: "x";
				padding: 0.2px;
				cursor: pointer;
				font-weight: bold;
				margin-left: 5px;
			}
			.check_cinema_li{
				background-color: #F3F8FF;
				height: 30px;
				line-height: 30px;
				margin-top: 2px;
			    padding-left: 10px;
			    cursor: pointer;
			    border-radius: 4px;
   			}
			.nocheck_cinema_li{
				background-color: #F3F8FF;
				height: 30px;
				line-height: 30px;
				margin-top: 2px;
				padding-left: 10px;
				cursor: pointer;
			    border-radius: 4px;
			}
			.checked_div{
				height: 239px;
			}
			.positionSelect .select_box{
				margin-left: 0px;
			}
			.positionSelect{
				margin-right: 50px !important;
			}
	    </style>
	</head>
	<body>
		<div class="cinema_tip">
		    <div class="cinema_subject clearfix">
		        <div class="cinema_title">
		            <a href="javascript:void(0);">用户中心</a> >
		            <a id="userinfo_list_href" href="${ctx}/sys/role/listRole">权限管理</a> >
		            <a href="javascript:void(0);" class="cinema_option">编辑权限</a>
		        </div>
		        <a href="${ctx}/sys/resource/list" class="movie_return">返回列表</a>
		    </div>
		</div>
		<div class="cinema_list">
			<form class="form-horizontal" onsubmit="return sysResourceInfoUpdate();" role="form" id="sysResourceUpateForm" name="sysResourceUpateForm" method="post">
				<div class="movie_list">
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p>名称：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="resName" type="text" name="resName" value="${resouce.resName}" class="validate[required,maxSize[100]]" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">URL：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="resUrl" type="text" name="resUrl" value="${resouce.resUrl}" class="width_320" maxlength="100" />
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">类型: </p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed positionSelect">
								<select id="type" name="type">
										<option class="department_opt" value="1" <c:if test="${resouce.type==1}">selected</c:if>>菜单</option>
										<option class="department_opt" value="2" <c:if test="${resouce.type==2}">selected</c:if>>按钮</option>
								</select>
							</div>
						</dd>
					</dl>
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">序号：</p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed">
								<input id="indexNum" type="text" name="indexNum" value="${resouce.indexNum}" class="width_320" maxlength="100" />
							</div>
						</dd>
					</dl>
					
					<div class="clearfix"></div>
					<dl class="movie_fill">
						<dt class="movie_word clearfix">
							<p style="background-image: none;">父菜单: </p>
						</dt>
						<dd class="mleft_99">
							<div class="movie_type cinema_feed positionSelect">
								<select id="parentId" name="parentId">
									<option class="department_opt" value="-1">无</option>
								<c:forEach var="list" items="${list}" varStatus="status">
									<option class="department_opt" value="${list.resourceId}" <c:if test="${list.resourceId==resouce.parentId}">selected</c:if>>${list.resName}</option>
								</c:forEach>		
								</select>
							</div>
						</dd>
					</dl>
					
					<input id="resourceId" type="hidden" name="resourceId" value="${resouce.resourceId}"/>
					<input id="resDesc" type="hidden" name="resDesc" value="${resouce.resDesc}"/>
					
					<div class="clearfix"></div>	
					<a class="movie_continue">
						<input type="submit" id="submit" value="提交" class="cinema_inquiry" />
					</a>
				</div>
			</form>
		</div>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine.js"></script>
		<script type="text/javascript" src="${ctx}/static/tools/jquery-validationEngine/jquery.validationEngine-cn.js"></script>
		<script type="text/javascript">
			function sysResourceInfoUpdate() {
				if ($("#sysResourceUpateForm").validationEngine("validate")) {
					var datastr = new Object();
	    			datastr.resName = $('#resName').val();
	    			datastr.resUrl = $('#resUrl').val();
	    			datastr.indexNum = $('#indexNum').val();
	    			datastr.parentId = $('#parentId').val();
	    			datastr.resDesc = $('#resDesc').val();
	    			datastr.type = $('#type').val();
	    			datastr.resourceId = $('#resourceId').val();
	    			alert(datastr.resourceId);
					var result = true;
					$.ajax({
	    		        async: true,
	    		        type:"POST",
	    		        data:JSON.stringify(datastr),
	    		        url: "${ctx}/sys/resource/update/"+datastr.resourceId,
	    		        dataType: "json",
	    		        headers : {  
	                        'Content-Type' : 'application/json;charset=utf-8'  
	                    },
	                    success : function(data) {
	                		if (data != undefined && data.status != undefined
	                				&& data.status.trim() == '0') {
	                			result = true;
	                			alert("修改成功！");
	                			//window.location.href = "${ctx}/sys/role/listRole";
	                		} else {
	                			result = false;
	                			alert(data.error);
	                		}
	                	},
	    			},"json");
				}
				return false;
			}
		</script>
	</body>
</html>